feat: Add scheduled/cron trigger support for periodic repository scans#10
feat: Add scheduled/cron trigger support for periodic repository scans#10
Conversation
This adds support for running skills on a schedule (cron), enabling periodic repository scans that analyze files matching configured path patterns, report findings via GitHub Issues, and optionally create fix PRs. Key changes: - Add 'schedule' event type to trigger configuration - Add ScheduleConfigSchema for schedule-specific options - Create schedule context builder for file-based analysis - Add issue renderer for GitHub Issue formatting - Add GitHub Issues module for issue/PR creation - Route schedule/workflow_dispatch events in action Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 3 potential issues.
Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.
| const path = f.location?.path ?? 'unknown'; | ||
| const line = f.location?.startLine ?? 0; | ||
| return `- **${f.title}** (${path}:${line})`; | ||
| }), |
There was a problem hiding this comment.
PR body lists all fixable findings, not just applied
Medium Severity
The PR body generation uses fixable.map() to list all findings that have a diff and path, but fixCount only increments when applyDiffToContent succeeds. If some fixes fail (caught at line 200), the PR will state "contains X automated fix(es)" but list more findings than were actually applied. This misleads reviewers about what changes the PR contains.
Additional Locations (1)
| }); | ||
|
|
||
| const matching = issues.find((issue) => issue.title === title); | ||
| return matching ? { number: matching.number, html_url: matching.html_url } : null; |
There was a problem hiding this comment.
Issue search may incorrectly match pull requests
Medium Severity
The findExistingIssue function uses octokit.issues.listForRepo which returns both issues and pull requests (GitHub treats PRs as issues in the API). The code doesn't filter out PRs before matching by title. If a PR exists with the same title as the tracking issue, it may be found instead, causing subsequent updates to modify the wrong entity.
| repo, | ||
| state: 'open', | ||
| per_page: 100, | ||
| }); |
There was a problem hiding this comment.
Missing pagination causes duplicate tracking issues in large repos
Medium Severity
The findExistingIssue function only fetches the first 100 open issues without pagination. GitHub's API returns issues sorted by creation date descending (newest first). If a repository has more than 100 open issues and the Warden tracking issue was created earlier, it won't appear in the first 100 results. This causes the function to return null, leading to duplicate tracking issues being created on subsequent scheduled runs instead of updating the existing one.
Summary
This PR adds support for scheduled/cron-based skill execution in Warden. This enables periodic repository scans that:
Motivation
Previously, Warden could only run skills in response to PR events. This limited its usefulness for:
With scheduled triggers, teams can now run comprehensive repository-wide scans on a regular cadence.
Key Design Insight
The existing runner already supports file-based analysis. The CLI's
buildFileEventContext()creates a syntheticpullRequestcontext from file globs, and the SDK runner processes it normally because the files have patch data.For scheduled runs, we adapt this pattern:
New Features
1. New
scheduleEvent TypeTriggers can now use
event = "schedule"to run on GitHub Actions schedule or workflow_dispatch events:2. Schedule-Specific Configuration
New
[triggers.schedule]section for schedule-specific options:3. GitHub Issue Reporting
Findings are rendered as a comprehensive GitHub Issue with:
If an issue with the same title already exists, it's updated rather than creating duplicates.
4. Automated Fix PRs
When
createFixPR = trueand skills providesuggestedFix.diff:Files Changed
New Files
src/event/schedule-context.tssrc/output/issue-renderer.tssrc/output/github-issues.tsModified Files
src/config/schema.tsscheduleevent,ScheduleConfigSchema, validation refinementssrc/types/index.tsscheduletoGitHubEventTypeSchemasrc/triggers/matcher.tssrc/action/main.tsrunScheduledAnalysis()handlersrc/event/index.tssrc/output/index.tsExample Configuration
warden.toml
.github/workflows/warden-scheduled.yml
Edge Cases Handled
Schema Validation
The schema enforces:
actionsis required for non-schedule eventsfilters.pathsis required for schedule events (must specify what to scan)Test Plan
workflow_dispatchevent🤖 Generated with Claude Code